import java.util.Arrays;
import java.util.PriorityQueue;

public class SolutionLCP24 {

    static class DuiDing{
        PriorityQueue<Integer> priorityQueue1=new PriorityQueue<>((a,b)->b-a);
        PriorityQueue<Integer> priorityQueue2=new PriorityQueue<>();
        long sum1=0,sum2=0;

        void insert(int k){
            if (priorityQueue1.isEmpty() || k<=priorityQueue1.peek()){
                priorityQueue1.offer(k);
                sum1+=k;
                if (priorityQueue1.size()-priorityQueue2.size()>1){
                    int t=priorityQueue1.poll();
                    sum1-=t;
                    priorityQueue2.offer(t);
                    sum2+=t;
                }
            }else {
                priorityQueue2.offer(k);
                sum2+=k;
                if (priorityQueue1.size()-priorityQueue2.size()<0){
                    int t=priorityQueue2.poll();
                    sum2-=t;
                    priorityQueue1.offer(t);
                    sum1+=t;
                }
            }
        }

        int getAns(){
            long t=priorityQueue1.peek();
            long a1=t*priorityQueue1.size()-sum1;
            long a2=sum2-t*priorityQueue2.size();
            return (int)((a1+a2)%1000000007);
        }
    }

    public int[] numsGame(int[] nums) {
        for (int i=0;i<nums.length;i++){
            nums[i]-=i;
        }
        int[] ans=new int[nums.length];
        DuiDing duiDing=new DuiDing();
        for (int i=0;i<nums.length;i++) {
            duiDing.insert(nums[i]);
            ans[i]=duiDing.getAns();
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new SolutionLCP24().numsGame(new int[]{471,626,848})));
    }
}
